<?php
/**
 * Created by PhpStorm.
 * User: liuwei
 * Date: 2022/12/16
 * Time: 14:13
 */

namespace App\Services\Company\Models;

use App\Services\Company\Models\CompanyOrder;
use App\Services\Company\Models\Company;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use function PHPUnit\Framework\isNull;

class CompanyTransfer extends Model
{

    use HasFactory;


    protected $table = 'shop_transfer';

    public const STATUS_CHECKING = 1;
    public const STATUS_RECEIVED = 2;
    public const STATUS_NOTRECEIVED = 3;



    protected $fillable = [
        'order_id','bank_name','account_name','account_id','company_id','user_id','status'
    ];

    public const STATUS_TEXT = [
        self::STATUS_CHECKING => '对账中',
        self::STATUS_RECEIVED => '已到账',
        self::STATUS_NOTRECEIVED => '未收到',
    ];
    protected $appends = [
        'status_text',
    ];
    public function getStatusTextAttribute()
    {
        return $this->statusText();
    }

    public function statusText(): string
    {
        return self::STATUS_TEXT[$this->status] ?? '';
    }

    public function order()
    {
        return $this->belongsTo(CompanyOrder::class, 'order_id');
    }

    public function company()
    {
        return $this->belongsTo(Company::class, 'company_id');
    }





}